Ext.onReady(function(){

	Ext.BLANK_IMAGE_URL = '/extjs-crud-grid/ext-3.2.1/resources/images/default/s.gif';


	Ext.QuickTips.init();

	// invalid markers to sides
	Ext.form.Field.prototype.msgTarget = 'side';
	
	
	//Form Initialisation
	
	
	var formRegister = new Ext.FormPanel({
			 xtype:'form'
			 ,id:'imginform-register'
			 ,defaultType:'textfield'
			 ,frame:true
			 ,method:'post'
			 ,url:'login/register.action'
			 ,defaults:{anchor:'95%'}
			 ,items:[{
				 fieldLabel:'First name'
					 ,id:'firstName'
				 },{
					 fieldLabel:'Last name'
					 ,id:'lastName'
				 },{
					 fieldLabel:'E-mail',
					 id:'email'
				},{
			 fieldLabel:'User name'
			 ,id:'username'
			 },{
			 fieldLabel:'Password',
			  inputType: 'password'
			 ,id:'password'
			 
			 }]
			 ,buttonAlign:'right'
			 ,buttons:[{
		            text: 'Reset',
		            handler: function(){
		            	formRegister.getForm().reset();
		            }
		        },
			           
			           {text:'Register' ,
			        	   handler:function() {
			        		   Ext.getCmp('imginform-register').getForm().submit(
			        				   {params:{cmd:'register'},
			        					   waitMsg: 'Registering...',
			        				   success: function() 
							           { 
			        					   	Ext.Msg.alert('Complete', 'Congratulations!! Registration Complete, Please login!'); 
			        					    window.location = 'login.jsp';
							           }
							           });
			        	   
			        		   
			        	   }
			           }		        	   
			           ]
			  
		 });
	
 
	 var win = new Ext.Window({
		 id:'RegisterForm'
		 ,width:300
		 ,height:200
		 ,layout:'fit'
		 ,border:false
		 ,closable:false
		 ,renderTo:Ext.getBody()
		 ,frame:true
		 ,title:'Register'
		 ,items:[formRegister]
		 });
		  
		 // show window
		 win.show();

});
